package com.runvp.common.enums;

/**
 * 设备出液口(01:1号出液口,02:2号出液口)
 */
public enum DevicePort implements BaseEnumInterface{
    PORT_ONE("01", "1号出液口"),
    PORT_TWO("02", "2号出液口");

    private String code;    //类型
    private String desc;    //描述
    private String defaulted;

    DevicePort(String code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    DevicePort(String code, String desc, String defaulted) {
        this.code = code;
        this.desc = desc;
        this.defaulted = defaulted;
    }

    @Override
    public String getCode() {
        return code;
    }

    @Override
    public String getDesc() {
        return desc;
    }

    @Override
    public String getDefaulted() {
        return defaulted;
    }

    /**
     * 是否包含枚举key值
     *
     * @param key
     * @return boolean true：包含，  false：不包含
     */
    public static boolean isContains(Integer key) {
        if (null == key || key == 0) {
            return false;
        }
        for (DevicePort e : DevicePort.values()) {
            if (key.equals(e.getCode())) {
                return true;
            }
        }
        return false;
    }
    /**
     * 获取枚举描述
     *
     * @param key
     * @return boolean true：包含，  false：不包含
     */
    public static String getValue(String key) {
        if (null == key || "".equals(key)) {
            return "未知";
        }
        for (DevicePort e : DevicePort.values()) {
            if (key.equals(e.getCode())) {
                return e.getDesc();
            }
        }
        return "未知";
    }
}
